package com.tensai.study.java.basic.datastructure.tree.binary;

import lombok.Data;

/**
 * @author Tensai
 */
@Data
public class BinaryTree {
    private String code;
    private String value;
    private Integer weight;
    private BinaryTree left;
    private BinaryTree right;

    public BinaryTree(String value, Integer weight) {
        this.value = value;
        this.weight = weight;
    }

    public BinaryTree(BinaryTree left, BinaryTree right) {
        this.setCode("");
        this.weight = left.getWeight() + right.getWeight();
        left.setCode("0");
        right.setCode("1");
        this.left = left;
        this.right = right;
    }
}
